﻿using System;
using System.Data;
using ET;

namespace DAL
{
    public class MCK_Holiday_DAL
    {
        private readonly clsConnect cls = new clsConnect();

        #region Getdata
        public DataTable GetData_MCK_Holiday(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KeyWords", keywords);
            return cls.GetData("sp_MCK_Holiday_Search");
        }
        public DataTable GetDataRow_MCK_Holiday(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Holiday_ID", id);
            return cls.GetData("sp_MCK_Holiday_SelectRow");
        }
        #endregion

        #region Insert
        public bool InsertMCK_Holiday(MCK_Holiday_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Holiday_Name", data.Holiday_Name);
            cls.AddParameter("@Start_Time", data.Start_Time);
            cls.AddParameter("@End_Time", data.End_Time);
            data.Holiday_ID = cls.ExecuteNonQueryReturnResult("sp_MCK_Holiday_Insert", "@ReferenceID");
            return true;
        }
        public bool InsertMCK_Holiday_Detail(int id, DateTime date)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Holiday_ID", id);
            cls.AddParameter("@Holiday_Date", date);
            return cls.ExecuteNonQuery("sp_MCK_Holiday_Detail_Insert");
        }
        #endregion

        #region Update
        public bool UpdateMCK_Holiday(MCK_Holiday_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Holiday_ID", data.Holiday_ID);
            cls.AddParameter("@Holiday_Name", data.Holiday_Name);
            cls.AddParameter("@Start_Time", data.Start_Time);
            cls.AddParameter("@End_Time", data.End_Time);
            return cls.ExecuteNonQuery("sp_MCK_Holiday_Update");
        }
        #endregion

        #region Delete
        public bool DeleteMCK_Holiday(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Holiday_ID", id);
            return cls.ExecuteNonQuery("sp_MCK_Holiday_DeleteRow");
        }
        public bool DeleteMCK_Holiday_Detail(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Holiday_ID", id);
            return cls.ExecuteNonQuery("sp_MCK_Holiday_Detail_DeleteRow");
        }
        #endregion
    }
}